package com.smart.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.smart.model.domain.DictDO;
import com.smart.model.request.DictRequest;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author zhanghong
 */
@Repository
public interface DictMapper extends BaseMapper<DictDO> {
    DictDO selectDOById(Long id);
    List<DictDO> selectDOList(DictDO dict);
    int insertDO(DictDO dict);
    int batchInsertDO(List<DictDO> dictDOList);
    int updateDO(DictDO dict);
    int deleteDOById(Long id);
    int deleteDOByIds(String[] ids);

    @Select({"<script>",
            "   select count(1) from dict",
            "   <where>",
            "       deleted=0",
            "       <if test=\"1==0\">and id=#{param.id}</if>",
            "   </where>",
            "</script>"})
    long pageCount(@Param("param") DictRequest param);
    @Select({"<script>",
            "   select * from dict",
            "   <where>",
            "       deleted=0",
            "       <if test=\"1==0\">and id=#{param.id}</if>",
            "   </where>",
            "   order by create_time desc limit #{limit} offset #{offset}",
            "</script>"})
    List<DictDO> pageQuery(@Param("param") DictRequest param, @Param("limit") int limit, @Param("offset") long offset);
}
